package com.snxun.browser_light.widget.webview;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.ViewGroup;
import android.webkit.WebSettings;

import com.lodz.android.pandora.widget.webview.PgWebView;
import com.lodz.android.pandora.widget.webview.PgWebViewClient;
import com.snxun.browser_light.R;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

/**
 * 自定义webview
 * Created by Yangjw on 2020/11/20.
 */
public class CustomPageWebView extends PgWebView {
    /**
     * 加载错误显示的视图
     */
    private ViewGroup mErrorLayout;


    public CustomPageWebView(@NotNull Context context) {
        super(context);

    }

    public CustomPageWebView(@NotNull Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public CustomPageWebView(@NotNull Context context, @Nullable AttributeSet attrs,
                             int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    public CustomPageWebView(@NotNull Context context, @Nullable AttributeSet attrs,
                             int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
    }

    public void setErrorLayout(ViewGroup errorLayout) {
        this.mErrorLayout = errorLayout;
    }

    @Override
    protected void initWebSettings(@NotNull WebSettings settings) {
        super.initWebSettings(settings);
    }

    @NotNull
    @Override
    protected PgWebViewClient createWebViewClient() {
        return new CustomPageWebViewClient(this, mErrorLayout);
    }

    public void reInit() {
        onInit();
    }

    @Override
    protected void onInit() {
        super.onInit();
    }
}
